package org.ii.infrastructure.web;


import org.springframework.web.servlet.mvc.UrlFilenameViewController;

/**
 * Custom {@link UrlFilenameViewController} that strips out portal information from the 
 * URI before handing over the responsibility to the super implementation.
 */
public class CustomUrlFilenameViewController extends UrlFilenameViewController {
	/*
	 * @author oystein.berg 2010 10 3
	 */
	@Override
	protected String extractViewNameFromUrlPath(String uri) {
		final int start = (uri.charAt(0) == '/' ? 1 : 0);
		final int lastIndex = uri.lastIndexOf(".");
		final int end = (lastIndex < 0 ? uri.length() : lastIndex);
		uri = uri.substring(start, end);
		return UrlUtil.getStrippedUrl(uri);
	}
}
